﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Controls_General_SideMenus_ProfileSideMenu : System.Web.UI.UserControl
{
    public BO.User User;
    protected void Page_Load(object sender, EventArgs e)
    {
        DisplayLogin();
    }

    protected void btnCreatAccount_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(tbMaName.Text))
            return;

        BO.MasterAccount account = new BO.MasterAccount
        {
            Name = tbMaName.Text,
            ProfileID = User.ProfileID.Value,
            EntityStatus = BLL.EntityStatuses.Active
        };

        account.Insert();

        Response.Redirect("MasterAccount.aspx?ID=" + account.ID.ToString());
    }

    private void DisplayLogin()
    {
        if (BLL.Authentication.IsCurrentUserAuthenticated())
        {
            lblLogin.Visible = false;
            lblLogout.Visible = true;
        }
        else
        {
            lblLogin.Visible = true;
            lblLogout.Visible = false;
        }

    }

    protected void lbtnLogout_Click(object sender, EventArgs e)
    {
        BLL.Authentication.Logout();
        Response.Redirect("/default.aspx");
    }
}